unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SIGNXLib_TLB, StdCtrls, OleCtnrs, RzEdit, ExtCtrls,
  RzPanel, RzSplit, OleServer, SVS_SOFT_COMLib_TLB;

type
  TForm1 = class(TForm)
    Btnx_1: TButton;
    Memo_A: TRzMemo;
    RzSplitter1: TRzSplitter;
    Btnx_3: TButton;
    Btnx_4: TButton;
    RzSplitter2: TRzSplitter;
    Memo_B: TRzMemo;
    Memo_C: TRzMemo;
    Btnx_2: TButton;
    Btnx_6: TButton;
    SignX1: TSignX;
    procedure Btnx_1Click(Sender: TObject);
    procedure Btnx_3Click(Sender: TObject);
    procedure Btnx_4Click(Sender: TObject);
    procedure Btnx_5Click(Sender: TObject);
    procedure Btnx_2Click(Sender: TObject);
    procedure Btnx_6Click(Sender: TObject);
    procedure SignX1EvenKeyStateNotify(ASender: TObject; lKeyType,
      lMsg: Integer);
    procedure FormShow(Sender: TObject);
    procedure SignX1Exit(Sender: TObject);
    procedure SignX1Enter(Sender: TObject);
  private
    FSignResult:WideString;
    FBase64Cert:WideString;
  public
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzUtils,ShellAPI;



{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
begin
  SignX1.SetSelectCertDialogMode(1);
  if SignX1.SelectCert=0 then
  begin
    SignX1.ShowDataBeforeSign(1);
    if SignX1.Sign('123456878-9-0002-0001',1)=0 then
    begin
      Memo_A.Lines.Clear;
      Memo_A.Lines.Add(SignX1.GetCurrentUsedCertInfo(9));
      Memo_C.Lines.Add(SignX1.GetCurrentUsedCertInfo(8));

      FBase64Cert:=SignX1.GetCurrentUsedCertInfo(9);
      FSignResult:=SignX1.GetSignResult;
      
      Memo_B.Lines.Clear;
      Memo_B.Lines.Add(FSignResult);
    end;
  end;
end;

procedure TForm1.Btnx_3Click(Sender: TObject);
begin
  SignX1.SetSelectCertDialogMode(1);
  if SignX1.SelectCert=0 then
  begin
    ShowMessage('true');
    Memo_B.Lines.Add(SignX1.GetCurrentUsedCertInfo(9));
  end;
end;

procedure TForm1.Btnx_4Click(Sender: TObject);
var
  NumbA:Integer;
  NumbB:Integer;
  NumbC:Integer;
  SignData:WideString;
  b64Cert:WideString;

  origndata:WideString;
begin
  {origndata:='123456878-9-0002-0001';


  NumbA:=SvsVerify1.InitialVerify('192.168.0.201',5000);
  TKzUtils.WritFmt('%D',[NumbA]);

  b64Cert:=SignX1.GetCurrentUsedCertInfo(9);
  
  NumbC:=SvsVerify1.VerifyCertSign(-1,-1,origndata,Length(origndata),b64Cert,FSignResult,1,NumbA);
  TKzUtils.WritLog(NumbC);}
end;

procedure TForm1.Btnx_5Click(Sender: TObject);
begin
  //
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
var
  dir: array [0..MAX_PATH] of Char;
begin
  //GetWindowsDirectory(dir, MAX_PATH);
  GetSystemDirectory(dir,MAX_PATH);
  ShowMessage(StrPas(dir));
end;

procedure TForm1.Btnx_6Click(Sender: TObject);
var
  PathA:string;
  TempA:string;
begin
  patha:='"c:\windows\system32\svs_soft_com.dll"';
  TempA:='regsvr32  %S';
  TempA:=Format(TempA,[(PathA)]);
  WinExec(PChar(tempa),SW_HIDE);
end;

procedure TForm1.SignX1EvenKeyStateNotify(ASender: TObject; lKeyType,
  lMsg: Integer);
begin
  TKzUtils.WritLog('true');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  if SignX1.SetEnableKeyNotify(1)=0 then
  begin
    TKzUtils.WritLog('active');
  end;  
end;

procedure TForm1.SignX1Exit(Sender: TObject);
begin
  TKzUtils.WritLog('exit');
end;

procedure TForm1.SignX1Enter(Sender: TObject);
begin
  TKzUtils.WritLog('enter');
end;

end.
